Repository navigation
Conversation
There was a problem hiding this comment.
ℹ️ Sound partial fix — no correctness or security regression on the code's own merits — but it is not mergeable as-is (it conflicts with current
main) and one durability gap undercuts the "across reloads" claim. Details below.
Reviewed changes
This run reviewed the three commits on the terminal/agent-prompt path that retire a dismissed Codex model-picker so its retained scrollback stops gating sendTerminalAgentPrompt.
- New
TerminalCodexModalObservationmodule — aWeakMap-backed retirement that slices a dismissed picker's prefix out of future wait text, fenced by pane generation, output sequence, and permission sequence. - Status/wait plumbing —
refreshModal,isModalComposerReady, andgetWaitTextthreaded throughRuntimeTerminalAgentStatusQuery, the idle polls, andRuntimeTerminalWait, replacing directbuildTerminalWaitTextcalls. - Write-gate tightening —
writeTerminalAgentPromptnow captures a pre-refresh baseline and compares permission sequence across the modal refresh (previously a self-comparison no-op). - Composer detection —
projectTerminalVisibleLinessurfaces whether the Codex composer placeholder is present, used to confirm the visible screen is a clean composer before retiring. - Two test files (~309 lines) covering fail-closed fencing, live-approval preservation, paste-echo retention, and permission cycles during the screen read.
⚠️ Conflicts with current main; not mergeable without a rebase
The branch is based on 28373fce and its merge-base with main (bba68b1) is 28373fce, so it sits behind a main that has moved well ahead. The author reports 9 conflict indicators and states they will not rebase or maintain the branch, so this cannot land as-is — the realistic paths are cherry-picking the observation module and tests, or closing. The rest of this review therefore evaluates the diff on its own merits rather than as a ready-to-merge change.
⚠️ Retirement is keyed by record identity, so it may not survive a renderer reload
TerminalCodexModalObservation.retired is a WeakMap keyed by the exact record object, and refreshModal / isModalComposerReady / getWaitText all select that object via getLivePty(handle)?.pty ?? getLiveLeaf(handle).leaf. A retirement recorded against the PTY record is invisible to a later read against the leaf record (and vice versa), and a graph reload that rebuilds the RuntimeLeafRecord / RuntimePtyWorktreeRecord objects drops the entry entirely. The pane then re-gates — safe (fail-closed), but it means the fix does not stick across the reload scenario that commit b872ca49 ("preserve synchronous terminal waiter admission across reloads") claims to address.
Technical details
# Reload durability of modal retirement
## Affected sites
- src/main/runtime/terminal-codex-modal-observation.ts:31 — `private readonly retired = new WeakMap<object, Retirement>()` (identity keyed)
- src/main/runtime/runtime-terminal-agent-status-query.ts:154 — `record` selected as `getLivePty(handle)?.pty ?? getLiveLeaf(handle).leaf`
- src/main/runtime/runtime-terminal-agent-status-query.ts:165 — `getWaitText(record, ptyId)` reads retirement against whichever record the caller passes
## Required outcome
- Retirement must survive the identity changes that occur across a renderer reload / graph re-sync, or be explicitly scoped as best-effort within a single projection.
## Open questions for the human
- Are leaf/pty records mutated in place or rebuilt on graph reload? If rebuilt, the `WeakMap` entry is lost and the "across reloads" claim does not hold.ℹ️ Nitpicks
getWaitTextcomputesgetModalFence(ptyId)— which lazily allocates a lifecycle generation viagetPtyLifecycleGeneration— on every read, even for non-Codex or non-retired panes. It could be gated onisCodex/ presence of a retirement.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| type Retirement = TerminalModalFence & { prefix: string } | ||
|
|
||
| // Only the model/effort picker can be retired without an agent lifecycle event. | ||
| export function hasCodexModelPickerTail(text: string): boolean { |
There was a problem hiding this comment.
The picker fingerprint here is pinned to exact Codex UI strings (Select model, reasoning effort, Press enter to confirm or esc to go back). A future Codex wording change silently disables retirement — safe, since it fails closed, but the fix stops firing with no signal. A log or metric when press enter to confirm is present but the model/effort context isn't would make that degradation visible.
📝 WalkthroughWalkthroughThe runtime now detects Codex composer state and observes model-picker modal output. Modal text is reconciled with lifecycle, output, and permission fences before it affects terminal status. Terminal waits and idle polls use modal-aware wait text. Prompt submission refreshes modal state before permission validation. New tests cover modal fencing, picker retirement, idle behavior, blocked screens, permission changes, and prompt submission. Priority: ⬇️ Low — Defer this runtime change because it addresses stale Codex modal observations gating terminal input within the terminal agent path. Merge Risk: 🟡 Moderate · up to Prompts can be admitted while an active model picker owns the terminal, and cancelled or short waits may remain blocked during modal refresh. These runtime behaviors should be corrected before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, scope, implementation, limitations, testing scope, and linked issue. However, it omits most required template sections, including Visual Proof, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It also does not provide the required visual proof or explicitly state N/A. Resolution Complete the repository template. Add the required sections and checklist items, provide before-and-after visual proof for the behavior change or write
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f2228e32-a888-413e-842d-7538d1cc998e
📒 Files selected for processing (14)
src/main/runtime/orca-runtime-core.tssrc/main/runtime/orca-runtime-create-agent-prompt-render-gate.tssrc/main/runtime/orca-runtime-get-terminal-interactive-wait.tssrc/main/runtime/orca-runtime-runtime-id.tssrc/main/runtime/orca-runtime-stop-requested-pty-ids.tssrc/main/runtime/orca-runtime-terminal-projection.tssrc/main/runtime/orca-runtime-write-terminal-agent-prompt.tssrc/main/runtime/runtime-terminal-agent-status-query.tssrc/main/runtime/runtime-terminal-idle-polls.tssrc/main/runtime/runtime-terminal-state-records.tssrc/main/runtime/runtime-terminal-wait.tssrc/main/runtime/terminal-codex-modal-observation.test.tssrc/main/runtime/terminal-codex-modal-observation.tssrc/main/runtime/terminal-codex-modal-runtime.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| try { | ||
| const ptyId = this.getTerminalAgentStatusPtyId(handle) | ||
| if (this.terminalAgentStatus.hasModalToRefresh(handle, ptyId)) { | ||
| await this.terminalAgentStatus.refreshModal(handle, ptyId) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
rg -n -C 12 'refreshModal|readVisibleTerminalState|terminalWait\.wait|waitForTerminal|renderer.*reload|reload.*renderer' src/mainRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- target file ---'
sed -n '1,190p' src/main/runtime/orca-runtime-create-agent-prompt-render-gate.ts
printf '%s\n' '--- definition files ---'
rg -l 'readVisibleTerminalState|refreshModal' src/main --glob '*.ts' --glob '*.tsx' | sort
printf '%s\n' '--- waiter definitions ---'
rg -l 'class .*Terminal.*Wait|terminalWait|waitForTerminal' src/main --glob '*.ts' --glob '*.tsx' | sort | head -80Repository: stablyai/orca
Length of output: 10423
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- status implementation locations ---'
rg -n -C 10 'refreshModal|readVisibleTerminalState|hasModalToRefresh|isModalComposerReady' \
src/main/runtime/runtime-terminal-agent-status-query.ts \
src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts \
src/main/runtime/orca-runtime-get-terminal-interactive-wait.ts \
src/main/runtime/orca-runtime-visible-snapshot-preview.ts
printf '%s\n' '--- waiter implementation ---'
sed -n '1,280p' src/main/runtime/runtime-terminal-wait.ts
printf '%s\n' '--- reload/read bindings ---'
rg -n -C 8 'readVisibleTerminalState|markRendererReloading|rendererGraph|reloading|webContents|executeJavaScript|invoke' \
src/main/runtime/runtime-terminal-agent-status-query.ts \
src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts \
src/main/runtime --glob '*.ts' | head -500Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- visible-state read implementation ---'
sed -n '30,145p' src/main/runtime/orca-runtime-visible-snapshot-preview.ts
printf '%s\n' '--- visible-state helpers and lifecycle invalidation ---'
rg -n -C 10 'loadVisibleTerminalState|providerVisibleStateReadsByPtyId|readRendererVisibleSnapshotLines|readVisibleState|clear.*Visible|delete\(ptyId\)|getPtyLifecycleGeneration' \
src/main/runtime/orca-runtime-visible-snapshot-preview.ts \
src/main/runtime/orca-runtime-capture-provider-terminal-buffer.ts \
src/main/runtime --glob '*.ts' | head -400Repository: stablyai/orca
Length of output: 42651
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- provider snapshot acquisition ---'
rg -n -C 18 'serializeProviderTerminalBuffer|VISIBLE_TERMINAL_SNAPSHOT_TIMEOUT_MS|withTimeout|providerSnapshotPreferredPtys' \
src/main/runtime/orca-runtime-capture-provider-terminal-buffer.ts \
src/main/runtime/orca-runtime-visible-snapshot-preview.ts \
src/main/runtime/runtime-async-boundaries.ts \
src/main/runtime --glob '*.ts' | head -500
printf '%s\n' '--- provider controller contract ---'
rg -n -C 12 'serializeProviderBuffer|serializeBuffer' src/main/runtime src/main/pty src/main --glob '*.ts' | head -350Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- provider buffer method ---'
sed -n '1,90p' src/main/runtime/orca-runtime-capture-provider-terminal-buffer.ts
printf '%s\n' '--- timeout contract ---'
rg -n -C 12 'export.*withTimeout|function withTimeout|promise-timeout-fallback|VISIBLE_TERMINAL_SNAPSHOT_TIMEOUT_MS' \
src/shared src/main/runtime --glob '*.ts' | head -220
printf '%s\n' '--- preferred-set transitions ---'
rg -n -C 8 'providerSnapshotPreferredPtys\.(add|delete)|providerSnapshotPreferredPtys\s*=' \
src/main/runtime --glob '*.ts' | head -260Repository: stablyai/orca
Length of output: 46085
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- bounded provider acquisition ---'
rg -n -C 18 'serializeProviderTerminalBuffer|class OrcaRuntimeWithSerializeTerminalBufferFromAvailableState' \
src/main/runtime/orca-runtime-serialize-terminal-buffer-from-available-state.ts
printf '%s\n' '--- headless write-chain construction ---'
rg -n -C 12 'writeChain\s*=|writeChain:|createPtyHeadlessTerminalState|acceptPtyData' \
src/main/runtime/orca-runtime-create-pty-headless-terminal-state.ts \
src/main/runtime/orca-runtime-serialize-main-terminal-buffer.ts \
src/main/runtime/orca-runtime-accept-pty-data.ts \
src/main/runtime --glob '*.ts' | head -450
printf '%s\n' '--- modal/reload tests ---'
rg -n -C 14 'refreshModal|readVisibleTerminalState|renderer reload|markRendererReloading|request_aborted|timeout' \
src/main/runtime/terminal-codex-modal-runtime.test.ts \
src/main/runtime/terminal-interactive-wait-visibility.test.ts \
src/main/runtime/orca-runtime-tests --glob '*.spec.ts' | head -500Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
sed -n '108,165p' src/main/runtime/orca-runtime-serialize-terminal-buffer-from-available-state.ts
printf '%s\n' '--- renderer reload lifecycle entry points ---'
rg -n -C 12 'markRendererReloading|markRendererGraph|renderer.*reloading|reloading.*renderer|disposeHeadlessTerminal|replaceHeadlessTerminalAfterExecutionContextChange' \
src/main/runtime/orca-runtime-*.ts | head -450Repository: stablyai/orca
Length of output: 45808
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- headless data chain ---'
sed -n '145,185p' src/main/runtime/orca-runtime-maybe-hydrate-headless-from-renderer.ts
printf '%s\n' '--- emulator write contract ---'
rg -n -C 15 'async write|write\(' src/main/daemon/headless-emulator.ts src/main/daemon --glob '*.ts' | head -260
printf '%s\n' '--- renderer reload implementation ---'
sed -n '20,115p' src/main/runtime/orca-runtime-has-terminals-for-worktree.tsRepository: stablyai/orca
Length of output: 27401
Preserve timeout and abort during modal refresh.
refreshModal does not use the caller's signal or deadline. Its provider path has a separate 750 ms timeout, while its headless path awaits writeChain without that deadline. Because this runs before terminalWait.wait binds the options, a short timeout or abort cannot take effect until the refresh returns. Register the waiter first, or apply the same signal and remaining timeout to the refresh.
|
|
||
| getWaitText(record: RuntimePtyWorktreeRecord | RuntimeLeafRecord, ptyId: string | null): string { | ||
| const text = buildTerminalWaitText(record.tailBuffer, record.tailPartialLine, record.preview) | ||
| return ptyId ? this.modal.read(record, text, this.deps.getModalFence(ptyId)) : text |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Reconcile a reopened picker before applying retirement.
TerminalCodexModalObservation.read ignores newer outputSequence values. A later identical picker in the same generation and permission sequence can therefore be stripped again. hasModalToRefresh then sees filtered text, skips refreshModal, and does not inspect the visible state. The wait path can admit tui-idle, allowing prompt submission while the picker is active. Detect the picker from raw wait text, clear retirement when newer visible state shows the active picker, and retain retirement only for confirmed composer echoes. Add a regression test for reopening the identical picker in one PTY generation.
|
@brennanb2025 @nwparker — pointer only, no action requested here. I've asked for a disposition on the underlying issue (#19589), since an independent reproduction has since landed in #20142 (Windows, 1.4.200) and nothing in v1.4.199–v1.4.204 touches the running-pane account switch. This PR itself stands as described in the original post: partial, unrebased (conflicts with current |
|
Added a dated section to the description: a second consequence of per-account |
|
Closing this abandoned partial PR as requested by its author. The PR states that it is unrebased, conflicts with current main, has not been CI-verified, and will not be maintained. The diagnosis and test ideas remain in this PR for reference; #19589 stays open for the underlying Codex account-switch issue. |

Partial fix for #19589. Please treat this as evidence, not as a finished contribution.
What this does
Three commits on the runtime terminal/agent-prompt path, addressing the piece of #19589 where a Codex pane's model-picker / rate-limit modal is observed and retired:
50162543d9a5197eb872ca4914 files, +492/−30, including two new test files (~309 lines):
terminal-codex-modal-observation.test.tsandterminal-codex-modal-runtime.test.ts. The new modulesrc/main/runtime/terminal-codex-modal-observation.ts(+82) is additive; the edits to existing runtime files are small.The motivating symptom: a walled Codex pane renders a modal ("Approaching rate limits — switch to a cheaper model?") that is a reminder painted over a session that has already stopped. We measured selecting it on 13 walled panes with cursor position verified and keystrokes confirmed delivered — 0 of 13 cleared. Meanwhile the observation state kept the pane's input gated. These commits make the runtime distinguish a retired modal from a live one and stop that gating from outliving the modal.
What this does NOT do
codexrather thancodex resume <session-id>.28373fce(fix(windows): repair the install-dir package ACL that blanks the window #17740), now well behindmain. Checked with a valid merge-base after unshallowing our clone: it conflicts with currentmain(9 conflict indicators) and needs a rebase we have not done.Honesty about provenance, since it affects how much you should trust it
These commits were written by one of our automated agents. It correctly diagnosed the underlying defect and then went considerably further than we intended — it cloned this repository and started writing fixes across five branches, consuming a large amount of our Codex quota before we noticed and stopped it. That was our process failure, not a problem with Orca.
We are opening this PR so the diagnosis is not wasted. We are not planning to invest further in fixing this, and we are not offering to maintain the branch. If it is useful, take it, rewrite it, or cherry-pick the tests. If it is not, close it without hesitation — no follow-up needed from our side, and we will not be offended.
The issue (#19589) is the more valuable half: it documents the asymmetry that Codex needs a 25-file stale-account/restart apparatus while Claude needs none.
Update 2026-09-19 — second asymmetry, same root: per-account
CODEX_HOMEsilently loses shared skillsWhile adding a skill for Codex we found that the per-account
CODEX_HOMEdesign in #19589 has a second cost beyond "panes cannot follow a switch": Orca-launched Codex seats do not see the user's skills, and nothing tells the user.Intended behaviour (present on
maintoday,src/main/codex/codex-home-paths.ts, last touched by0b80a773a4/ #15287):CODEX_SYSTEM_RESOURCE_ENTRIESlistsskills,hooks,plugins,plugin-state,profile-v2,themes,prompts,AGENTS.md, andsyncSystemCodexResourcesIntoManagedHome()is meant to symlink each of them from~/.codexinto every managed home, so a per-account launch home "is complete without ever symlinking into or mutating the user's real ~/.codex".Observed (Orca 1.4.205, Codex CLI 0.154.0, macOS, 6 Codex accounts):
AGENTS.md~/.codex/AGENTS.mdin 6/6pluginscache/) in 1/6skills~/.codex/skills.system/andcache/So every account home had
AGENTS.mdand the globalconfig.tomlfrom~/.codex, and none of the three skills installed in~/.codex/skills. A skill added by the documented Codex route (~/.codex/skills/<name>/SKILL.md) is therefore invisible in every Orca-launched Codex pane, while the same user's Claude panes see all of~/.claude/skillsbecause Claude account switching persists only auth and never swapsCLAUDE_CONFIG_DIR(global-settings-types.ts:287says exactly that).Why the link is missing: Codex CLI materialises
$CODEX_HOME/skills/.system/(its bundled skills) andplugins/cache/itself on first launch. If that happens beforelinkSystemCodexResourceruns for the entry, or after the entry is removed, the target is now a real directory that Orca did not create.linkSystemCodexResourcethen takes the branchand returns without a log line (the only
console.warns in that function are for a non-fileAGENTS.mdand for copy fallbacks). That branch is correct for user-created runtime resources, but a directory whose only contents are Codex's own.system/is not user content, and the silence is what turned a race into six permanently divergent homes.Suggested fix, in ascending ambition:
warnwhen a system resource is skipped because the target is a foreign real directory, naming the home and the entry. This alone would have surfaced the defect on day one.skills/target that contains only Codex-owned entries (.system/,cache/) as replaceable: move it aside and install the link, or link the individual~/.codex/skills/*children into it..system/whenever it is absent.Workaround we applied locally (per home): move the real
skills/aside andln -s ~/.codex/skills "$HOME/skills"; all six homes now list the same four skills. A newly added account will hit the same race until the ordering or the skip branch changes.Filed here rather than as a separate issue because it is the same root cause as #19589: binding identity into
CODEX_HOMEforces Orca to re-create the user's whole Codex environment per account, and every entry it re-creates is a place it can silently diverge. Happy to split it into its own issue if you prefer.